#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>   
using namespace std;
int maxPointsInsideSquare(vector<vector<int>>& points, string s) {
    //包含的最大字符数
    int count = 0;
    unordered_map<char,long long> map;
    for(int i=0;i<s.size();i++)
    {
        //若遍历的字母已存在map中并且值为0
        if(map.find(s[i])!= map.end())
        {
            int lenth1 = abs(points[i][0]);
            int lenth2 = abs(points[i][1]);
            int min = lenth1>lenth2?lenth1:lenth2;
            if(map[s[i]]==-100000000 || map[s[i]]>min)
                map[s[i]] = min;
        }
        else
            map[s[i]] = -100000000;
    }
    //此时找到了第一次包含重复元素时的矩阵的边长
    long long theSecondMIn = 100000000;
    for(const auto& item : map)
    {
        cout<<item.first<<": "<<item.second<<endl;
        if(item.second<theSecondMIn &&  item.second!=-100000000)
            theSecondMIn = item.second;
    }
    cout<<"the max lenth:"<<theSecondMIn<<endl;
    for (const auto& point : points) {
        int x = abs(point[0]);
        int y = abs(point[1]);
        if (x < theSecondMIn && y < theSecondMIn) {
            ++count;
            //cout<<"the count:"<<count;
        }
    }
    //cout<<"the count:"<<count;
    return count;
}
int main()
{
    string s;
    vector<vector<int>> points(4);
    cout<<"enter the string: "<<endl;
    cin>>s;
    cout<<"enter the points: "<<endl;
    for(int i=0;i<4;++i){
        for(int j=0;j<2;++j){
            int x;
            cin>>x;
            points[i].push_back(x);
        }
    }
    int max = maxPointsInsideSquare(points,s);
    cout<<"the max points are: "<<max;
    return 0;
}
